home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk.zip / MAWK.H < prev    next >
C/C++ Source or Header  |  1991-04-07  |  4KB  |  143 lines

  1.  
  2. /********************************************
  3. mawk.h
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the Awk programming language as defined in
  8. Aho, Kernighan and Weinberger, The AWK Programming Language,
  9. Addison-Wesley, 1988.
  10.  
  11. See the accompaning file, LIMITATIONS, for restrictions
  12. regarding modification and redistribution of this
  13. program in source or binary form.
  14. ********************************************/
  15.  
  16.  
  17. /*   $Log:    mawk.h,v $
  18.  * Revision 2.1  91/04/08  08:23:33  brennan
  19.  * VERSION 0.97
  20.  * 
  21. */
  22.  
  23.  
  24. /*  mawk.h  */
  25.  
  26. #ifndef  MAWK_H
  27. #define  MAWK_H   
  28.  
  29. #include  "machine.h"
  30.  
  31. #ifdef   DEBUG
  32. #define  YYDEBUG  1
  33. extern  int   yydebug ;  /* print parse if on */
  34. extern  int   dump_RE ;
  35. #endif
  36. extern  int   dump_code ;
  37.  
  38. #ifdef  __STDC__
  39. #define  PROTO(name, args)   name  args
  40. #undef   HAVE_VOID_PTR
  41. #define  HAVE_VOID_PTR          1
  42. #else
  43. #define  PROTO(name, args)   name()
  44. #endif 
  45.  
  46.  
  47. #include <stdio.h>
  48. #include <string.h>
  49. #include "types.h"
  50.  
  51.  
  52. /*----------------
  53.  *  GLOBAL VARIABLES
  54.  *----------------*/
  55.  
  56. /* some well known cells */
  57. extern CELL cell_zero, cell_one ;
  58. extern STRING  null_str ;
  59. /* a useful scratch area */
  60. extern union tbuff temp_buff ;
  61. extern char *main_buff ; /* main file input buffer */
  62.  
  63. /* help with casts */
  64. extern int pow2[] ;
  65.  
  66.  
  67.  /* these are used by the parser, scanner and error messages
  68.     from the compile  */
  69.  
  70. extern  int current_token ;
  71. extern  unsigned  token_lineno ; /* lineno of current token */
  72. extern  unsigned  compile_error_count ;
  73. extern  int  paren_cnt, brace_cnt ;
  74. extern  int  print_flag, getline_flag ;
  75.  
  76.  
  77. /*---------*/
  78.  
  79. extern  int  errno ;     
  80. extern  char *progname ; /* for error messages */
  81.  
  82. /* macro to test the type of two adjacent cells */
  83. #define TEST2(cp)  (pow2[(cp)->type]+pow2[((cp)+1)->type])
  84.  
  85. /* macro to get at the string part of a CELL */
  86. #define string(cp) ((STRING *)(cp)->ptr)
  87.  
  88. #ifdef   DEBUG
  89. #define cell_destroy(cp)  DB_cell_destroy(cp)
  90. #else
  91.  
  92. #define cell_destroy(cp)   if ( (cp)->type >= C_STRING &&\
  93.                                 -- string(cp)->ref_cnt == 0 )\
  94.                                 zfree(string(cp),string(cp)->len+5);else
  95. #endif
  96.  
  97. /*  prototypes  */
  98.  
  99. void  PROTO( cast1_to_s, (CELL *) ) ;
  100. void  PROTO( cast1_to_d, (CELL *) ) ;
  101. void  PROTO( cast2_to_s, (CELL *) ) ;
  102. void  PROTO( cast2_to_d, (CELL *) ) ;
  103. void  PROTO( cast_to_RE, (CELL *) ) ;
  104. void  PROTO( cast_for_split, (CELL *) ) ;
  105. void  PROTO( check_strnum, (CELL *) ) ;
  106. void  PROTO( cast_to_REPL, (CELL *) ) ;
  107.  
  108. int   PROTO( test, (CELL *) ) ; /* test for null non-null */
  109. CELL *PROTO( cellcpy, (CELL *, CELL *) ) ;
  110. CELL *PROTO( repl_cpy, (CELL *, CELL *) ) ;
  111. void  PROTO( DB_cell_destroy, (CELL *) ) ;
  112. void  PROTO( overflow, (char *, unsigned) ) ;
  113. void  PROTO( rt_overflow, (char *, unsigned) ) ;
  114. void  PROTO( rt_error, ( char *, ...) ) ;
  115. void  PROTO( mawk_exit, (int) ) ;
  116. void PROTO( da, (INST *, FILE *)) ;
  117. int  PROTO( space_split, (char *) ) ;
  118. char *PROTO( str_str, (char*, char*, unsigned) ) ;
  119. int   PROTO( re_split, (char *, PTR) ) ;
  120. char *PROTO( re_pos_match, (char *, PTR, unsigned *) ) ;
  121.  
  122. void  PROTO( exit, (int) ) ;
  123. int   PROTO( close, (int) ) ;
  124. int   PROTO( open, (char *,int, int) ) ;
  125. int   PROTO( read, (int , PTR, unsigned) ) ;
  126. char *PROTO( getenv, (const char *) ) ;
  127.  
  128. int  PROTO ( parse, (void) ) ;
  129. int  PROTO ( yylex, (void) ) ;
  130. int  PROTO( yyparse, (void) ) ;
  131. void PROTO( yyerror, (char *) ) ;
  132.  
  133. void PROTO( bozo, (char *) ) ;
  134. void PROTO( errmsg , (int, char*, ...) ) ;
  135. void PROTO( compile_error, ( char *, ...) ) ;
  136.  
  137. INST *PROTO( execute, (INST *, CELL *, CELL *) ) ;
  138. char *PROTO( find_kw_str, (int) ) ;
  139.  
  140. double strtod(), fmod() ;
  141.  
  142. #endif  /* MAWK_H */
  143.